// These locations are the regions where the default system and monitoring sku types are available (last checked 12/19/2023)
export const AzureLocationOptions = [
  { value: "australiaeast", label: "Australia East" },
  { value: "brazilsouth", label: "Brazil South" },
  { value: "canadacentral", label: "Canada Central" },
  { value: "centralindia", label: "Central India" },
  { value: "centralus", label: "Central US" },
  { value: "eastasia", label: "East Asia" },
  { value: "eastus", label: "East US" },
  { value: "eastus2", label: "East US 2" },
  { value: "francecentral", label: "France Central" },
  { value: "northeurope", label: "North Europe" },
  { value: "norwayeast", label: "Norway East" },
  { value: "southafricanorth", label: "South Africa North" },
  { value: "southcentralus", label: "South Central US" },
  { value: "swedencentral", label: "Sweden Central" },
  { value: "switzerlandnorth", label: "Switzerland North" },
  { value: "uaenorth", label: "UAE North" },
  { value: "uksouth", label: "UK South" },
  { value: "westeurope", label: "West Europe" },
  { value: "westus2", label: "West US 2" },
  { value: "westus3", label: "West US 3" },
];

export type MachineTypeOption = {
  value: string;
  label: string;
  resources: { vCPU: number; RAM: number; GPU?: number };
  supportedRegions: Set<string>;
};

export const azureSupportedMachineTypes = (
  region: string,
  gpu?: boolean
): MachineTypeOption[] => {
  return AzureMachineTypeOptions.filter(
    (option) =>
      option.supportedRegions.has(region) && !!option.resources.GPU === !!gpu
  );
};

export const azureMachineTypeDetails = (
  type: string
): MachineTypeOption | undefined => {
  const matches = AzureMachineTypeOptions.filter(
    (option) => option.value === type
  );

  if (matches.length === 0) {
    return undefined;
  }

  return matches[0];
};

// Retrieve updated list of supported regions by running the following command: az vm list-skus --all --output table | grep <INSTANCE_TYPE> | grep 1,2,3 | grep None | awk '{print "\047" tolower($2) "\047"}' | paste -s -d, -
// last updated 12/19/2020
//
// NOTE: Any new instance types must be added to the cluster-control-plane preflight checks until we are able to dynamically handle new instances.
const AzureMachineTypeOptions: MachineTypeOption[] = [
  {
    value: "Standard_B2als_v2",
    label: "Standard_B2als_v2",
    resources: { vCPU: 2, RAM: 4 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "brazilsouth",
      "canadacentral",
      "centralindia",
      "centralus",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "southcentralus",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "westeurope",
      "westus2",
      "westus3",
    ]),
  },
  {
    value: "Standard_B2as_v2",
    label: "Standard_B2as_v2",
    resources: { vCPU: 2, RAM: 8 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "brazilsouth",
      "canadacentral",
      "centralindia",
      "centralus",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "southcentralus",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "westeurope",
      "westus2",
      "westus3",
    ]),
  },
  {
    value: "Standard_A2_v2",
    label: "Standard_A2_v2",
    resources: { vCPU: 2, RAM: 4 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "germanywestcentral",
      "israelcentral",
      "italynorth",
      "northeurope",
      "norwayeast",
      "polandcentral",
      "southafricanorth",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
    ]),
  },
  {
    value: "Standard_A4_v2",
    label: "Standard_A4_v2",
    resources: { vCPU: 4, RAM: 8 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "germanywestcentral",
      "israelcentral",
      "italynorth",
      "northeurope",
      "norwayeast",
      "polandcentral",
      "southafricanorth",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
    ]),
  },
  {
    value: "Standard_DS1_v2",
    label: "Standard_DS1_v2",
    resources: { vCPU: 1, RAM: 3.5 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "germanywestcentral",
      "israelcentral",
      "italynorth",
      "northeurope",
      "norwayeast",
      "polandcentral",
      "southafricanorth",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
    ]),
  },
  {
    value: "Standard_DS2_v2",
    label: "Standard_DS2_v2",
    resources: { vCPU: 2, RAM: 7 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "germanywestcentral",
      "israelcentral",
      "italynorth",
      "northeurope",
      "norwayeast",
      "polandcentral",
      "southafricanorth",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "eastus2euap",
      "israelcentral",
      "italynorth",
      "polandcentral",
      "qatarcentral",
      "swedencentral",
      "switzerlandnorth",
      "westus3",
    ]),
  },
  {
    value: "Standard_D2ads_v5",
    label: "Standard_D2ads_v5",
    resources: { vCPU: 2, RAM: 8 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "koreacentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "swedencentral",
      "uaenorth",
      "uksouth",
      "westus3",
    ]),
  },
  {
    value: "Standard_B4als_v2",
    label: "Standard_B4als_v2",
    resources: { vCPU: 4, RAM: 8 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "brazilsouth",
      "canadacentral",
      "centralindia",
      "centralus",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "southcentralus",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "westeurope",
      "westus2",
      "westus3",
    ]),
  },
  {
    value: "Standard_B8als_v2",
    label: "Standard_B8als_v2",
    resources: { vCPU: 8, RAM: 16 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "brazilsouth",
      "canadacentral",
      "centralindia",
      "centralus",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "southcentralus",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "westeurope",
      "westus2",
      "westus3",
    ]),
  },
  {
    value: "Standard_B16als_v2",
    label: "Standard_B16als_v2",
    resources: { vCPU: 16, RAM: 32 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "brazilsouth",
      "canadacentral",
      "centralindia",
      "centralus",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "northeurope",
      "norwayeast",
      "southafricanorth",
      "southcentralus",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
      "westeurope",
      "westus2",
      "westus3",
    ]),
  },
  {
    value: "Standard_DC1s_v2",
    label: "Standard_DC1s_v2",
    resources: { vCPU: 1, RAM: 4 },
    supportedRegions: new Set<string>(["eastus", "westeurope"]),
  },
  {
    value: "Standard_DC2s_v2",
    label: "Standard_DC2s_v2",
    resources: { vCPU: 2, RAM: 8 },
    supportedRegions: new Set<string>(["eastus", "westeurope"]),
  },
  {
    value: "Standard_DC4s_v2",
    label: "Standard_DC4s_v2",
    resources: { vCPU: 4, RAM: 16 },
    supportedRegions: new Set<string>(["eastus", "westeurope"]),
  },
  {
    value: "Standard_DC8_v2",
    label: "Standard_DC8_v2",
    resources: { vCPU: 8, RAM: 32 },
    supportedRegions: new Set<string>(["eastus", "westeurope"]),
  },
  {
    value: "Standard_NC4as_T4_v3",
    label: "Standard_NC4as_T4_v3",
    resources: { vCPU: 4, RAM: 28, GPU: 1 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "centralindia",
      "eastus",
      "eastus2",
      "japaneast",
      "northeurope",
      "southcentralus",
      "southeastasia",
      "uksouth",
      "westeurope",
      "westus2",
    ]),
  },
  {
    value: "Standard_NC8as_T4_v3",
    label: "Standard_NC8as_T4_v3",
    resources: { vCPU: 8, RAM: 56, GPU: 1 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "centralindia",
      "eastus",
      "eastus2",
      "japaneast",
      "northeurope",
      "southcentralus",
      "southeastasia",
      "uksouth",
      "westeurope",
      "westus2",
    ]),
  },
  {
    value: "Standard_NC16as_T4_v3",
    label: "Standard_NC16as_T4_v3",
    resources: { vCPU: 16, RAM: 110, GPU: 1 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "centralindia",
      "eastus",
      "eastus2",
      "japaneast",
      "northeurope",
      "southcentralus",
      "southeastasia",
      "uksouth",
      "westeurope",
      "westus2",
    ]),
  },
  {
    value: "Standard_NC64as_T4_v3",
    label: "Standard_NC64as_T4_v3",
    resources: { vCPU: 64, RAM: 440, GPU: 4 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "centralindia",
      "eastus",
      "eastus2",
      "japaneast",
      "northeurope",
      "southcentralus",
      "southeastasia",
      "uksouth",
      "westeurope",
      "westus2",
    ]),
  },
  {
    value: "Standard_D8s_v3",
    label: "Standard_D8s_v3",
    resources: { vCPU: 8, RAM: 32 },
    supportedRegions: new Set<string>([
      "australiaeast",
      "canadacentral",
      "centralindia",
      "eastasia",
      "eastus",
      "eastus2",
      "francecentral",
      "germanywestcentral",
      "israelcentral",
      "italynorth",
      "northeurope",
      "norwayeast",
      "polandcentral",
      "southafricanorth",
      "southeastasia",
      "swedencentral",
      "switzerlandnorth",
      "uaenorth",
      "uksouth",
    ]),
  },
];
